package com.zmn.oms.dubbo.impl.normal.order;

import cn.hutool.core.bean.BeanUtil;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.oms.common.dro.tag.OrderTagDetailsDRO;
import com.zmn.oms.dubbo.interfaces.normal.order.OrderTagListRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.entity.tag.OrderTag;
import com.zmn.oms.services.interfaces.tag.OrderTagService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 类描述：工单标签查询服务
 *
 * @author fudifang
 * @date 2022/6/30 11:03
 */
@Slf4j
@Service(loadbalance = "roundrobin", timeout = 10000, retries = 0, version = DubboConsts.INTERFACE_VERSION, validation = "true")
public class OrderTagListRemoteServiceImpl implements OrderTagListRemoteService {

    @Resource
    private OrderTagService orderTagService;

    @Override
    public ResponseDTO<List<OrderTagDetailsDRO>> listOrderTagByOrderIdAndTagId(Long orderId, Integer tagId) {
        log.info("OrderTagListRemoteServiceImpl#listOrderTagByOrderIdAndTagId 根据订单id和标签id查询工单标签接口入参：【orderId：{}，tagId：{}】", orderId, tagId);
        try {
            List<OrderTag> orderTagList = orderTagService.listOrderTagByOrderIdAndTagId(orderId, tagId);
            return ResponseDTO.success(BeanUtil.copyToList(orderTagList, OrderTagDetailsDRO.class));
        } catch (Exception e) {
            e.printStackTrace();
            log.info("根据订单id和标签id查询工单标签失败：{}", e);
            return ResponseDTO.fail(e.getMessage());
        }
    }

}
